![]() |
PATH![]() |
![]() ![]() |
The Repeat While form of the Repeat statement repeats a group of statements as long as a particular condition, specified in a Boolean expression, is met.
repeat while Boolean
[ statement ]...
end [ repeat ]
Boolean is an expression whose value is true or false . The statements in the loop are repeated until Boolean becomes false . If Boolean is false when entering the loop, the statements in the loop are not executed.
The following example numbers the paragraphs of a document with the Repeat While form of the Repeat statement. To type the greater than or equal character (≥), press Option-greater-than sign.
tell document "Simple" of application "AppleWorks"
set numParagraphs to (count paragraphs of text body)
set paragraphNum to 1
repeat while paragraphNum numParagraphs
set paragraph paragraphNum of text body ¬
to (paragraphNum as string) & " " ¬
& paragraph paragraphNum of text body
set paragraphNum to paragraphNum + 1
end repeat
end tell